home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / DClap / DTableView-c0.h < prev    next >
Text File  |  1996-07-05  |  5KB  |  164 lines

  1. // DTableView.h
  2. // d.g.gilbert
  3.  
  4. #ifndef _DTABLEVIEW_
  5. #define _DTABLEVIEW_
  6.  
  7. #include "DPanel.h"
  8. #include "DCommand.h"
  9. #include "DTracker.h"
  10. #include "DMethods.h"
  11.  
  12.  
  13. class DTabSelector;
  14.  
  15. class DTableView : public DAutoPanel, public DPrintHandler
  16. {
  17. public:
  18.         enum { kNoSelection = -1, kExtend = true, kHighlight= true, kSelect= true };
  19.         DTabSelector * fTabSelector; 
  20.         DTracker * fCurrentTracker;
  21.         
  22.         DTableView(long id, DView* itsSuperior,  
  23.                     short pixwidth, short pixheight, 
  24.                     short nrows, short ncols,
  25.                     short itemwidth, short itemheight,
  26.                     Boolean hasVscroll = true, Boolean hasHscroll = true);
  27.         virtual ~DTableView();
  28.         
  29.         virtual void SetCanSelect( Boolean canrow, Boolean cancol);
  30.         virtual void SetTableFont( Nlm_FonT itsFont);
  31.         virtual void SetTableSize( short rows, short cols);
  32.         virtual void ChangeRowSize( short atrow, short deltarows);
  33.         virtual void ChangeColSize( short atcol, short deltacols);
  34.         
  35.         virtual void SetItemWidth(short atcol, short ncols, short itemwidth);
  36.         virtual void SetItemHeight(short atrow, short nrows, short itemheight);
  37.         virtual void SetScrollPage();
  38.         
  39.         virtual void FindLocation();
  40.         virtual void Resize(DView* superview, Nlm_PoinT sizechange);
  41.         virtual void SizeToSuperview( DView* super, Boolean horiz, Boolean vert);
  42.         virtual void ViewRect(Nlm_RecT& r); 
  43.  
  44.         virtual void Scroll(Boolean vertical, DView* scrollee, short newval, short oldval);
  45.         virtual void ScrollIntoView( Nlm_RecT itemr);
  46.             
  47.         virtual void GetRowRect( short row, Nlm_RecT& r, short nrows = 1);
  48.         virtual void GetColRect( short col, Nlm_RecT& r, short ncols = 1);
  49.         virtual void GetCellRect( short row, short col, Nlm_RecT& r);
  50.         virtual void GetCellRect( Nlm_RecT cellr, Nlm_RecT& r);
  51.         virtual short GetSelectedRow();
  52.         virtual short GetSelectedCol();
  53.         virtual void GetFirstSelectedCell( short& row, short& col);
  54.         virtual void GetLastSelectedCell( short& row, short& col);
  55.         virtual void PointToCell(Nlm_PoinT mouse, short& row, short& col);
  56.             
  57.         virtual void SelectCells( short row, short col, 
  58.                 Nlm_Boolean extend = false, Nlm_Boolean highlight = true, Nlm_Boolean select = true);
  59.         virtual void SelectCells( Nlm_RecT selrect,  
  60.                 Nlm_Boolean extend = false, Nlm_Boolean highlight = true, Nlm_Boolean select = true);
  61.         virtual void SetEmptySelection(Boolean redraw = true);
  62.         virtual void InvalidateSelection();
  63.         virtual Boolean IsSelected();
  64.         virtual Boolean IsSelected(short row, short col);
  65.         virtual void InvertSelection();
  66.  
  67.         virtual void TrackFeedback( short aTrackPhase,
  68.                     const Nlm_PoinT& anchorPoint, const Nlm_PoinT& previousPoint,
  69.                     const Nlm_PoinT& nextPoint, Nlm_Boolean mouseDidMove, Nlm_Boolean turnItOn);
  70.         virtual void TrackMouse( short aTrackPhase,
  71.                     Nlm_PoinT& anchorPoint, Nlm_PoinT& previousPoint,
  72.                     Nlm_PoinT& nextPoint,    Nlm_Boolean mouseDidMove);
  73.         
  74.         virtual void SingleClickAt(short row, short col);
  75.         virtual void DoubleClickAt(short row, short col);
  76.         virtual void Click(Nlm_PoinT mouse);
  77.         virtual void Drag(Nlm_PoinT mouse);
  78.         virtual void Release(Nlm_PoinT mouse);
  79.  
  80.         virtual void DrawCell(Nlm_RecT r, short row, short col);
  81.         virtual void DrawRow(Nlm_RecT r, short row);
  82.         virtual void Draw();
  83.         virtual void InvertRect( Nlm_RecT& r);
  84.         virtual void Print();
  85.         virtual void WriteToPICT(DFile* afile); 
  86.         virtual void GetPageCount(Nlm_RecT pagerect, short& rowpages, short& colpages);
  87.         
  88.         Nlm_FonT GetFont() { return fFont; }
  89.         void SelectFont() { Nlm_SelectFont(fFont); }
  90.         short GetMaxRows() { return fMaxRows; }
  91.         short GetMaxCols() { return fMaxCols; }
  92.         short GetItemWidth() { return fItemWidth; }
  93.         short GetItemHeight() { return fItemHeight; }
  94.         Nlm_RecT GetRect() { return fRect; }
  95.         Nlm_RecT GetSelRect() { return fSelrect; }
  96.         short    GetLeft() { return fLeft; }
  97.         short GetTop()    { return fTop; }
  98.         void SetLeft( short val) { fLeft = val; }
  99.         void SetTop( short val)    { fTop = val; }
  100.         
  101. protected:
  102.         short        *fWidths, *fHeights;
  103.         short        fMaxRows, fMaxCols;
  104.         short        fItemHeight, fItemWidth;
  105.         short        fTop, fLeft, fSelectedRow, fSelectedCol, fColsDrawn;
  106.         Boolean fCanSelectRow, fCanSelectCol;
  107.         Boolean    fHasVbar, fHasHbar, fIsPrinting;
  108.         Nlm_RecT    fRect;
  109.         Nlm_RecT    fSelrect;
  110.         Nlm_FonT    fFont;
  111. };
  112.  
  113.  
  114.  
  115. class DTabSelector : public DTracker 
  116. {
  117. public:
  118.     enum { cTabSelCmd = 2421 };
  119.     Nlm_RecT    fOldSelection, fNewSelection; //Nlm_RgN later ...
  120.     Boolean     fDoExtend;
  121.     
  122.     DTabSelector( DTableView* itsTable);
  123.     virtual ~DTabSelector();
  124.     virtual void ITabSelector( DTableView* itsTable);
  125.     virtual void Reset(); 
  126.     virtual void DoIt(); 
  127.     virtual void Undo();
  128.     virtual void Redo(); 
  129.     virtual void DoItWork(); 
  130.     virtual void UndoWork(); 
  131. };
  132.  
  133. class DRCshifter : public DTracker 
  134. {
  135. public:
  136.     enum { kDoCol= 0, kDoRow= 1 };
  137.     Nlm_Boolean fRowCol;
  138.     short             fNewRC, fOldRC;
  139.     DTableView    * fTable;
  140.     
  141.     DRCshifter() 
  142.     {
  143.         IRCshifter( 0, NULL, NULL, kDoRow, 0);
  144.     }
  145.         
  146.     DRCshifter( long command, DTaskMaster* itsSource, DTableView* itsTable, 
  147.                             Nlm_Boolean RowOrCol, short oldRC) 
  148.     {
  149.          IRCshifter( command, itsSource, itsTable, RowOrCol, oldRC);
  150.     }
  151.          
  152.     void IRCshifter( long command, DTaskMaster* itsSource, DTableView* itsTable, 
  153.                             Nlm_Boolean RowOrCol, short oldRC)
  154.     {
  155.          fTable= itsTable; fRowCol= RowOrCol; fNewRC= -1; fOldRC= oldRC;
  156.          ITracker(command,  itsSource, "shift", kCanUndo, kCausesChange,
  157.                                  itsTable);
  158.     }
  159.      
  160. };
  161.  
  162.  
  163. #endif
  164.